<?php
require_once "header_before_menu.php";
require_once "db.php";
require_once "util.php";
require_once "header_editor.php";

get_database_connection();

$title = $_REQUEST["title"];
$content = $_REQUEST["content"];
$object_id = $_SESSION["object_id"];

// Getting the last position used
$sql = "SELECT position from slides order by id desc limit 1";
$res = mysql_query($sql);
$fetch = mysql_fetch_array($res);
$position = $fetch["position"] + 1;

// Inserting
$sql = "INSERT INTO slides (title, content, position, object_id)
        VALUES ('$title', '$content', '$position', '$object_id');";
$res = mysql_query($sql);

set_flash("Pagina adicionada com exito.");
ddd_redirect("index.editor.php");
?>

